JPath Transformer

The jpath transformer is just like the xpath one where you can use XPath expressions, but in this case you're applying them to JSON objects.

The JPath works very similarly to the XPath usage but the difference is the data being operated on is a JSON object. The nice thing is the language doesn't change at all so if we had a JSON object contained in a property like so:

  
  { 
    "list": [
             { "id": "1001", "type": "Regular" },
             { "id": "1002", "type": "Chocolate" },
             { "id": "1003", "type": "Blueberry" },
             { "id": "1004", "type": "Devil's Food" }
            ]
  }
   
 

Say we wanted to be able to get the 3rd element in the a list and just print the value of the attribute type, here's how we could easily log that exact part of the JSON object:

  ${json_array:jpath:/list[3]/@type}
 

Its pretty easy to see that the power of using XPath expressions against JSON objects allows you to do a lot more with your JSON data in your test than you could possibly imagine.